<!-- 页面入口 -->
<template>
    <div class="main-wrap">
        <div class="main-left-warp">
            <div class="logo">
                <img class="nav-logo" src="../../image/main/toolbar/logo.svg" />
            </div>
            <div :class="[$route.meta.key === item.key ? 'left-item left-item-active' : 'left-item']" v-for="(item, index) in treeList" :key="index" @click="menuClick(item)">
                <img :src="item.url">
                {{item.name}}
            </div>
            <div class="left-item-bottom">
                <div :class="[$route.meta.key === item.key ? 'left-item left-item-active' : 'left-item']" v-for="(item, index) in treeListBottom" :key="index" @click="menuClick(item)">
                    <img :src="item.url">
                    {{item.name}}
                </div>
            </div>
        </div>
        <div class="main-box-warp">
            <!-- <div class="main-header" v-if="user.getPanel() !== 'true'">
                <img class="nav-logo" src="../../image/main/main_header_person.svg" />
                <el-dropdown>
                    <div class="el-dropdown-link user-icon">
                        <img class="nav-logo" src="../../image/main/main_header_person.svg" />
                    </div>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item @click.native.stop="quitVisible = true">退出登录</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
                <el-dropdown>
                    <div class="el-dropdown-link user-icon">
                        <img class="nav-logo" src="../../image/main/main_header_person.svg" />
                    </div>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item>{{ config.data.version }}</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </div> -->
            <div class="main-title">
                {{$route.meta.title}}
            </div>
            <div class="main-router">
                <transition name="fade-transform" mode="out-in">
                    <router-view />
                </transition>
            </div>
        </div>
        <el-dialog title="提示" :visible.sync="quitVisible" width="500px" top="35vh">
            <div>此操作将退出，是否继续?</div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="quitVisible = false">取 消</el-button>
                <el-button type="primary" @click="quitProject">退 出</el-button>
            </span>
        </el-dialog>
        <el-dialog title="关于" :visible.sync="aboutVisible" width="300px" top="35vh">
            <div>版本信息：{{ config.data.version }}</div>
        </el-dialog>
    </div>
</template>

<script>
import PATH from '@/js/util/path.js';
import user from '@/js/util/user.js';
import menu from '@/js/main/menu.js';
import config from '@/js/util/config.js';

export default {
    data() {
        return {
            quitVisible: false,
            treeList: menu.menuTree,
            treeListBottom: menu.menuTreeBottm,
            user: user,
            config: config,
            actived: 0,
            aboutVisible: false
        };
    },
    methods: {
        menuClick(row) {
            if (row.key === 'OPTION' || row.key === 'ABOUT') {
                this.aboutVisible = true;
                return false;
            }
            this.$router.push({ path: PATH[row.key] });
        },
        quitProject() {
            user.removeToken();
            this.$router.push({ path: PATH.LOGIN });
        }
    }
};
</script>

<style lang='scss' scoped>
.main-wrap {
    display: flex;
    background: #1A1919;
    width: $CalcVW;
    height: $CalcVH;
    .main-left-warp {
        width: 240px;
        height: 100%;
        // background: #313131;
        background: #212121;
        border-radius: 1px;
        box-shadow: #000000 1px 0 1px;
        position: relative;
        .logo { 
            height: 90px;
            display: flex;
            align-items: center;
            .nav-logo {
                width: 150px;
                margin-left: 33px;
            }
        }
        .left-item {
            width: 212px;
            height: 40px;
            font-size: 14px;
            font-weight: 400;
            color: #e3e3e3;
            margin: 1px auto;
            display: flex;
            align-items: center;
            cursor: pointer;
            font-family: 'simHei';
            img {
                width: 16px;
                height: 16px;
                margin: 0 15px 0 24px;
            }
            &:hover {
                background: #323A42;
                border-radius: 4px; 
            }
        }
        .left-item-active {
            background: #323A42;
            border-radius: 4px;
        }
        .left-item-bottom {
            position: absolute;
            bottom: 20px;
            width: 100%;
            &::before {
                content: '';
                width: 212px;
                height: 1px;
                background: #373737;
                position: absolute;
                top: -10px;
                left: 50%;
                transform: translateX(-50%);
                -ms-transform: translateX(-50%);
                -webkit-transform: translateX(-50%);
                -o-transform: translateX(-50%);
            }
        }
    }
    .main-box-warp {
        height: 100%;
        width: calc(100% - 240px);
        overflow: hidden;
        padding: 42px 42px 0 42px;
        .main-header {
            height: 90px;
            display: flex;
            align-items: center;
            justify-content: right;
            img {
                cursor: pointer;
            }
        }
        .main-title {
            // height: 33px;
            font-size: 16px;
            font-weight: 700;
            color: #ffffff;
            // line-height: 33px;
            font-family: 'simHei';
            letter-spacing: 1px;
        }
        .main-router {
            height: 100%;
            // height: calc(100% - 123px);
        }
    }
    .main-box-warp-panel {
        width: 100%;
    }
}

::v-deep.el-dropdown-menu__item {
    color: $FontWhite;
}

::v-deep.el-dropdown-menu__item:focus,
.el-dropdown-menu__item:not(.is-disabled):hover {
    background: #151720 !important;
}

::v-deep.el-dropdown-menu__item:focus,
.el-dropdown-menu__item:not(.is-disabled):hover {
    background: transparent;
}
</style>